package com.edu.spring.ioc.bean;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.Data;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

@Data
public class User implements InitializingBean, DisposableBean {
    private String username;
    private String password;

    public void initUser() {
        System.out.println(" @Bean 初始化：initUser");
    }

    public void destroyUser() {
        System.out.println(" @Bean 销毁：destroyUser");
    }

    public User() {
        System.out.println("构造器----");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("postConstruct...");
        username = "10";
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("preDestroy ... ");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy....");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet....");
    }
}

